package org.sky.wechat.action;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.sky.common.web.action.BaseAction;
import org.sky.util.XmlAnalyzeUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("phone/wechat")
public class BaseApiAction {
	protected Logger log=LoggerFactory.getLogger(this.getClass());
	@RequestMapping(value="api",method = {RequestMethod.GET})
	public void check(HttpServletRequest request,HttpServletResponse response,String echostr) throws IOException{
		log.info(echostr);
		response.getWriter().write(echostr);
	}
	
	@RequestMapping(value="api",method = {RequestMethod.POST})
	public void getMessage(HttpServletRequest request,HttpServletResponse response) throws IOException{
		String xml = XmlAnalyzeUtil.getXml(request);
		log.info(xml);
		response.getWriter().write("");
	}
}
